package com.example.cd5160866.urlapp;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MainActivity extends ListActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        String[] itmes = {"demo1", "demo2", "demo3", "demo4", "demo5", "demo6", "demo7", "demo8"};
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                R.layout.item_list, R.id.tv_item, itmes);
        this.setListAdapter(adapter);

    }

    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        switch (position) {
            case 0:
                startActivity(new Intent(MainActivity.this, Demo1Activity.class));
                break;
            case 1:
                startActivity(new Intent(MainActivity.this, Demo2Activity.class));
                break;
            case 2:
                startActivity(new Intent(MainActivity.this, Demo3Activity.class));
                break;
            case 3:
                startActivity(new Intent(MainActivity.this, Demo4Activity.class));
                break;
            case 4:
                startActivity(new Intent(MainActivity.this, Demo5Activity.class));
                break;
            case 5:
                startActivity(new Intent(MainActivity.this, Demo6Activity.class));
                break;
            case 6:
                startActivity(new Intent(MainActivity.this, Demo7Activity.class));
                break;
            case 7:
                startActivity(new Intent(MainActivity.this, Demo8Activity.class));
                break;

            default:
                break;
        }
        super.onListItemClick(l, v, position, id);
    }

    @Override
    protected void onResume() {
        super.onResume();
        Log.d("qw","onResume");
    }

    @Override
    protected void onStart() {
        super.onStart();
        Log.d("qw","onStart");
    }

    @Override
    protected void onPause() {
        super.onPause();
        Log.d("qw","onPause");
    }

    @Override
    protected void onStop() {
        super.onStop();
        Log.d("qw","onStop");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.d("qw","onDestroy");
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        Log.d("qw","onSaveInstanceState");
    }

    @Override
    protected void onRestoreInstanceState(Bundle state) {
        super.onRestoreInstanceState(state);
        Log.d("qw","onRestoreInstanceState");
    }
}
